package com.qq.clone.user.Db.Mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qq.clone.user.Db.DO.UserDO;
import org.apache.ibatis.annotations.Mapper;


@Mapper
public interface UserMapper extends BaseMapper<UserDO> {
    default Long findUserIdByUsername(String username) {
        UserDO userDO = selectOne(new LambdaQueryWrapper<UserDO>().eq(UserDO::getUsername, username)
                .select(UserDO::getUserId));
        return userDO == null ? null : userDO.getUserId();
    }
}